package b.d;

import android.app.KeyguardManager;
import android.content.Context;
import android.content.Intent;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.util.Log;
import androidx.biometric.DeviceCredentialHandlerActivity;
import androidx.fragment.app.FragmentActivity;
import b.d.c.a.a;

/* compiled from: Utils */
public class j {
    public static boolean a() {
        b bVar = b.j;
        return bVar != null && bVar.g;
    }

    public static boolean b(Context context, String str, int i) {
        if (str == null) {
            return false;
        }
        for (String startsWith : context.getResources().getStringArray(i)) {
            if (str.startsWith(startsWith)) {
                return true;
            }
        }
        return false;
    }

    public static void c(String str, FragmentActivity fragmentActivity, Bundle bundle, Runnable runnable) {
        if (fragmentActivity instanceof DeviceCredentialHandlerActivity) {
            KeyguardManager keyguardManager;
            DeviceCredentialHandlerActivity deviceCredentialHandlerActivity = (DeviceCredentialHandlerActivity) fragmentActivity;
            if (VERSION.SDK_INT >= 23) {
                keyguardManager = (KeyguardManager) deviceCredentialHandlerActivity.getSystemService(KeyguardManager.class);
            } else {
                Object systemService = deviceCredentialHandlerActivity.getSystemService("keyguard");
                if (systemService instanceof KeyguardManager) {
                    keyguardManager = (KeyguardManager) systemService;
                } else {
                    Log.e(str, "Failed to check device credential. KeyguardManager not found.");
                    deviceCredentialHandlerActivity.x(0);
                    return;
                }
            }
            if (keyguardManager == null) {
                Log.e(str, "Failed to check device credential. KeyguardManager was null.");
                deviceCredentialHandlerActivity.x(0);
                return;
            }
            CharSequence charSequence;
            CharSequence charSequence2 = null;
            if (bundle != null) {
                charSequence2 = bundle.getCharSequence("title");
                charSequence = bundle.getCharSequence("subtitle");
            } else {
                charSequence = null;
            }
            Intent createConfirmDeviceCredentialIntent = keyguardManager.createConfirmDeviceCredentialIntent(charSequence2, charSequence);
            if (createConfirmDeviceCredentialIntent == null) {
                Log.e(str, "Failed to check device credential. Got null intent from Keyguard.");
                deviceCredentialHandlerActivity.x(0);
                return;
            }
            b a = b.a();
            a.g = true;
            a.i = 2;
            if (runnable != null) {
                ((a) runnable).run();
            }
            createConfirmDeviceCredentialIntent.setFlags(134742016);
            deviceCredentialHandlerActivity.startActivityForResult(createConfirmDeviceCredentialIntent, 0);
            return;
        }
        Log.e(str, "Failed to check device credential. Parent handler not found.");
    }

    public static boolean d(Context context, String str) {
        if (VERSION.SDK_INT != 28) {
            return false;
        }
        return b(context, str, 2130903050);
    }
}
